local jixi = fk.CreateSkill {
  name = "ls__jixi",
}

Fk:loadTranslationTable{
  ["ls__jixi"] = "急袭",
  [":ls__jixi"] = "弃牌阶段开始前，你可视为使用【暗度陈仓】，{你可令此牌效果改为额外交给目标角色一张牌，}，然后此阶段改为出牌阶段。",
  [":ls__jixi_fix"] = "弃牌阶段开始前，你可视为使用【暗度陈仓】，然后此阶段改为出牌阶段。",
  ["#ls__jixi-target"] = "急袭：你可视为使用【暗度陈仓】",

  ["$ls__jixi1"] = "兵行险招者，岂可按部就班。",
  ["$ls__jixi2"] = "唯急袭，方可攻不备。",
}

jixi:addEffect(fk.EventPhaseChanging, {
  dynamic_desc = function(self, player)
    if player:getMark("ls__jixi-turn") > 0 then
      return "ls__jixi_fix"
    end
    return "ls__jixi"
  end,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(jixi.name) and data.phase == Player.Discard and not data.skipped
  end,
  on_cost = function(self, event, target, player, data)
    local use = player.room:askToUseVirtualCard(player, {
      name = "lvshi__secret_advance",
      skill_name = jixi.name,
      prompt = "#ls__jixi-target",
      cancelable = true,
      skip = true,
    })
    if use then
      event:setCostData(self, {use = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local use = event:getCostData(self).use
    use = player.room:useCard(use)
    if player:getMark("jixi_buff-phase") > 0 then
      data.phase = Player.Play
    end
  end,
})

jixi:addEffect(fk.PreCardEffect, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(jixi.name) and data.from == player and data.card.skillName == jixi.name
  end,
  on_use = function(self, event, target, player, data)
    data:changeCardSkill("ls_jixi__secret_advance_skill")
  end,
})

return jixi
